Clustering and Segmentation in Tableau
1. Introduction to Clustering and Segmentation
Clustering and Segmentation are important data analysis techniques used to identify groups of similar records, customers, products, regions, or business entities. In Tableau, clustering helps analysts discover hidden patterns in data and divide similar marks into groups based on selected variables.
Segmentation is the broader process of dividing data into meaningful categories for analysis and decision-making. Clustering is one technique used to create segments automatically based on similarities in the data.
For example, an e-commerce company can analyze customer spending, order frequency, and purchase value to discover groups such as high-value customers, occasional buyers, and low-spending customers.
Learning Objectives
- Understand the meaning of clustering and segmentation.
- Learn how Tableau identifies clusters.
- Understand the K-means clustering algorithm.
- Create clusters using the Analytics pane.
- Choose suitable variables for clustering.
- Interpret and describe cluster results.
- Save clusters as groups for reuse.
- Build interactive segmentation dashboards.
2. What Is Clustering?
Clustering is an unsupervised machine learning technique that divides observations into groups called clusters. Observations within the same cluster are generally more similar to one another than observations belonging to different clusters.
In Tableau, clustering can group marks in a visualization according to selected variables. Tableau assigns different colors to the resulting clusters so users can identify patterns visually.
Example
Suppose a retail company has customer data containing annual spending, number of orders, and average order value. Clustering may reveal three groups:
- Cluster 1: Customers who spend frequently and have high purchase values.
- Cluster 2: Customers who make occasional purchases with moderate spending.
- Cluster 3: Customers who purchase infrequently and spend relatively little.
These are illustrative interpretations. Actual clusters depend on the available data, selected variables, and model configuration.
3. What Is Segmentation?
Segmentation is the process of dividing a larger population or dataset into smaller groups based on shared characteristics. Segments can be defined using business rules, demographic attributes, categories, or statistical techniques such as clustering.
Examples of Segmentation
- Customer segmentation: Dividing customers by spending, loyalty, or purchasing behavior.
- Product segmentation: Grouping products according to price, sales, or profitability.
- Geographic segmentation: Dividing markets into regions or territories.
- Sales segmentation: Grouping sales representatives by performance.
- Employee segmentation: Comparing employee groups using relevant workforce metrics.
- Risk segmentation: Grouping accounts according to defined risk indicators.
4. Difference Between Clustering and Segmentation
| Feature |
Clustering |
Segmentation |
| Meaning |
Groups observations according to similarities discovered by an algorithm. |
Divides a population into meaningful groups. |
| Approach |
Usually data-driven and unsupervised. |
Can use business rules, existing categories, or statistical methods. |
| Group Creation |
Determined by the clustering model and input variables. |
Defined by analysts, business rules, or models. |
| Example |
Automatically discovering groups of customers with similar purchase patterns. |
Classifying customers as new, returning, or loyal based on predefined rules. |
| Purpose |
Discover hidden structure in data. |
Make groups easier to understand and act upon. |
| Tableau Use |
Use the Cluster feature in the Analytics pane. |
Use groups, sets, calculated fields, filters, or clustering results. |
5. Importance of Clustering and Segmentation
- Customer understanding: Discover groups with similar purchasing behavior.
- Marketing optimization: Develop targeted campaigns for different customer groups.
- Sales analysis: Identify products and regions with similar performance patterns.
- Business planning: Understand which groups need different strategies.
- Pattern discovery: Find relationships that may not be obvious in raw tables.
- Resource allocation: Focus resources on groups with particular business needs.
- Performance comparison: Compare sales, profit, and other measures across clusters.
- Dashboard reporting: Present complex data in understandable groups.
6. Understanding Unsupervised Learning
Clustering is generally considered an unsupervised learning technique because it does not require a predefined target label for every observation. Instead, the algorithm looks for patterns in the input variables.
Supervised vs. Unsupervised Learning
| Feature |
Supervised Learning |
Unsupervised Learning |
| Training Data |
Uses labeled examples with known outcomes. |
Uses data without a predefined target label. |
| Goal |
Predict an outcome or class. |
Discover structure, patterns, or groups. |
| Example |
Predict whether a customer will cancel a subscription. |
Group customers according to purchasing behavior. |
| Common Methods |
Regression and classification. |
Clustering and dimensionality reduction. |
7. How Clustering Works in Tableau
Tableau uses the K-means clustering algorithm for its built-in clustering feature. K-means attempts to divide marks into a specified number of clusters so that each mark belongs to a cluster with a relatively nearby center.
Main Steps
- Select variables: Choose the measures or supported fields that describe the marks.
- Set the number of clusters: Specify the number of groups or allow Tableau to select a suitable number.
- Initialize cluster centers: The algorithm starts with initial centers for the clusters.
- Assign marks: Each mark is assigned to the nearest cluster center.
- Recalculate centers: The center of each cluster is recalculated using its assigned observations.
- Repeat: Assignments and centers are refined until the algorithm converges.
- Display results: Tableau colors marks by cluster and provides options for examining the results.
8. Understanding the K-Means Algorithm
K-means is a clustering algorithm that partitions data into K clusters. Each cluster has a centroid representing the mean of the observations assigned to it for the numerical variables used by the model.
Example
A company wants to group customers using two variables: annual spending and number of orders. If K equals 3, the algorithm attempts to create three clusters with similar customers grouped together.
Input Data
Customer ID | Annual Spending | Orders
C001 | 50000 | 20
C002 | 45000 | 18
C003 | 10000 | 4
C004 | 12000 | 5
C005 | 30000 | 12
Clustering Process
1. Select the input variables.
2. Initialize cluster centers.
3. Assign customers to the nearest center.
4. Recalculate cluster centers.
5. Repeat assignments until convergence.
6. Review the resulting customer groups.
The customer groups shown in this example are not predetermined; the algorithm determines membership from the data and model settings.
Important K-Means Concepts
- K: The number of clusters.
- Centroid: The center of a cluster, calculated as the mean of its assigned points.
- Distance: A measure of how close an observation is to a cluster center.
- Iteration: A repeated step in which cluster assignments and centers are updated.
- Convergence: The point at which further iterations no longer change cluster assignments.
9. Preparing Data for Clustering
Data preparation is essential because clustering results depend on the fields selected, the quality of the data, and the level of detail in the visualization.
Step 1: Connect to the Dataset
Open Tableau Desktop and connect to a suitable source, such as Excel, CSV, or a supported database.
Step 2: Check Data Types
- Ensure numerical measures are stored as numeric fields.
- Check that customer IDs or product IDs identify the intended records.
- Verify that dimensions contain meaningful categories.
- Review missing, null, or inconsistent values.
Step 3: Choose the Level of Detail
Decide what each mark should represent. For customer segmentation, each mark may represent one customer. For product segmentation, each mark may represent one product.
If the view aggregates several customers into a single mark, the resulting clusters may represent aggregated groups rather than individual customers.
Step 4: Select Useful Variables
Choose variables that relate to the business question. For customer analysis, useful measures might include total sales, order count, average order value, and days since the last purchase.
Step 5: Review Data Quality
Investigate outliers, duplicate records, missing values, and fields that may not contribute useful information. Tableau can assign records with missing clustering measures to a Not Clustered category.
10. Creating Clusters in Tableau
Tableau provides a built-in Cluster feature in the Analytics pane. Follow these steps to create a cluster analysis.
- Open Tableau Desktop and connect to a dataset.
- Create a visualization appropriate for the data.
- Choose the level of detail, such as one mark per customer.
- Add relevant measures to the view or Marks card.
- Open the Analytics pane.
- Drag Cluster into the visualization, or double-click Cluster.
- Tableau creates a Clusters field and colors the marks by cluster.
- Review the Clusters dialog box.
- Add or remove variables from the Variables area.
- Specify the number of clusters, if desired.
- Close the dialog box to review the results.
- Interpret the clusters using the measures and dimensions available in the view.
In Tableau Desktop, the number of clusters can be specified between 2 and 50. If the number is not specified, Tableau selects a cluster count automatically, up to its default search limit of 25.
11. Selecting Variables for Clustering
Variables are the fields used by the algorithm to compare marks and determine cluster membership. Selecting appropriate variables is one of the most important decisions in clustering.
| Business Objective |
Possible Variables |
Potential Insight |
| Customer Segmentation |
Total Sales, Order Count, Average Order Value |
Groups with different purchase patterns. |
| Product Segmentation |
Sales, Profit, Quantity Sold |
Groups of products with similar commercial performance. |
| Regional Segmentation |
Sales, Profit Margin, Customer Count |
Regions with similar performance characteristics. |
| Employee Analysis |
Experience, Training Hours, Performance Score |
Groups with similar workforce metrics. |
| Marketing Analysis |
Campaign Spend, Conversions, Clicks |
Campaigns with similar performance profiles. |
Best Practices for Choosing Variables
- Choose fields that relate directly to the business question.
- Avoid including many redundant measures that describe nearly the same thing.
- Check the units and ranges of numerical variables.
- Consider whether extreme values could dominate the interpretation.
- Ensure that the data contains enough observations to identify useful patterns.
- Test different variable combinations and compare the business meaning of the results.
12. Scaling and Normalization
Variables can have very different numerical ranges. For example, annual revenue may range into millions, while order frequency may range from 1 to 100. If variables are not scaled appropriately, a large numerical range can dominate distance calculations.
Tableau's built-in clustering feature automatically uses min-max normalization for its clustering inputs. This maps each numeric variable to a scale between 0 and 1 when the variable has a nonzero range.
Min-Max Normalization
Normalized Value = (x - Minimum) / (Maximum - Minimum)
Example:
Minimum Revenue = 10
Maximum Revenue = 110
Observed Revenue = 60
Normalized Value = (60 - 10) / (110 - 10)
Normalized Value = 50 / 100
Normalized Value = 0.5
Normalization helps reduce the influence of differences in numerical scale, but it does not remove the effect of unusual outliers. Review the data and interpretation before relying on the clusters.
13. Choosing the Number of Clusters
The number of clusters affects the level of detail in a segmentation. Too few clusters may combine distinct patterns, while too many clusters may create groups that are difficult to interpret or act upon.
Examples
- 2 clusters: A broad division into two groups.
- 3 clusters: A simple low, medium, and high pattern, if supported by the data.
- 4 clusters: A more detailed segmentation for additional comparison.
- 5 or more clusters: Useful when the dataset supports more detailed distinctions and each group remains meaningful.
These labels are possible interpretations, not guaranteed outcomes. Tableau does not automatically know which group should be called high-value or low-value; analysts must examine cluster characteristics.
Automatic Cluster Selection
When Tableau selects the number of clusters automatically, it evaluates cluster quality using the Calinski-Harabasz criterion. This criterion compares separation between clusters with variation within clusters. A larger value generally indicates more distinct clusters relative to their internal spread.
Use automatic selection as a starting point, then compare alternative cluster counts for stability, interpretability, and business usefulness.
14. Understanding Cluster Results
After Tableau creates clusters, examine the variables and characteristics of each group. Do not assume that Cluster 1 is better or more valuable than Cluster 2 just because of its number or color.
Questions to Ask
- How many observations belong to each cluster?
- Which variables distinguish one cluster from another?
- What are the typical values for each measure within a cluster?
- Are there unusually small or large clusters?
- Do the groups correspond to meaningful business behavior?
- Would different variables or a different cluster count produce a more useful segmentation?
15. Describing Clusters in Tableau
Tableau provides a Describe Clusters dialog box to help inspect cluster characteristics and model information.
- Find the Clusters field on the Marks card.
- Right-click the Clusters field.
- Select Describe Clusters.
- Review the Summary tab for variables, the number of clusters, and cluster statistics.
- Review the Models tab for statistical information about the variables.
- Use the displayed centers, counts, and other statistics to interpret the groups.
Important Statistics
| Statistic |
Meaning |
Interpretation |
| Number of Clusters |
The number of clusters produced by the model. |
Shows how many groups were created. |
| Number of Points |
The number of marks included in the clustering view. |
Shows the number of observations represented by the marks. |
| Cluster Size |
The number of marks assigned to a particular cluster. |
Helps identify large and small groups. |
| Cluster Centers |
Average numerical values for variables within each cluster. |
Helps characterize each group's typical profile. |
| Between-Group Sum of Squares |
Measures variation between cluster centers and the overall center. |
Larger separation can indicate more distinct groups. |
| Within-Group Sum of Squares |
Measures variation of marks around their cluster centers. |
Smaller values indicate tighter groups, though the value also depends on the number of clusters. |
| F-Statistic |
Measures the relative variation between and within groups for a variable. |
Can help identify variables that distinguish clusters. |
16. Saving Clusters as Groups
After creating clusters, you may want to reuse them in other worksheets, filters, or dashboards. Tableau allows cluster results to be saved as a group dimension.
Steps to Save a Cluster Group
- Locate the Clusters field on the Marks card.
- Drag the Clusters field to the Data pane.
- Tableau creates a group dimension containing the cluster members.
- Rename the group members when useful.
- Use the saved group dimension in other worksheets and visualizations.
The saved group and the original clustering result become separate objects. Changes to the original clustering do not automatically update the saved group, and editing the saved group does not change the original model results.
17. Editing and Renaming Clusters
Editing Clusters
- Right-click the Clusters field on the Marks card.
- Select Edit Clusters.
- Add or remove variables.
- Change the number of clusters if needed.
- Review the updated visualization.
Renaming Clusters
To use meaningful business names, first save the clustering result as a group. Then edit the saved group and rename its members.
For example, after reviewing customer behavior, an analyst might label groups as Frequent High-Value Customers, Occasional Customers, and Low-Activity Customers. These names should be based on the actual cluster characteristics rather than assumptions.
18. Practical Project: Customer Segmentation
Project Objective
Use Tableau clustering to identify groups of customers according to their purchase behavior and develop a dashboard for business analysis.
Sample Dataset
| Customer ID |
Annual Sales |
Orders |
Average Order Value |
| C001 |
₹1,20,000 |
24 |
₹5,000 |
| C002 |
₹1,00,000 |
20 |
₹5,000 |
| C003 |
₹25,000 |
5 |
₹5,000 |
| C004 |
₹18,000 |
3 |
₹6,000 |
| C005 |
₹60,000 |
12 |
₹5,000 |
| C006 |
₹35,000 |
7 |
₹5,000 |
The sample values are illustrative. A real clustering model needs enough observations to identify meaningful patterns, and its results may differ from any expected business categories.
Project Steps
- Connect the customer dataset to Tableau.
- Create a view with one mark per customer.
- Add Annual Sales and Orders as measures in the view or Marks card.
- Open the Analytics pane.
- Drag Cluster into the visualization.
- Choose a suitable number of clusters or begin with automatic selection.
- Review the cluster assignments and add Average Order Value if relevant.
- Open Describe Clusters to inspect the model statistics.
- Save the cluster results as a group if they need to be reused.
- Build charts comparing the number of customers, total sales, and average order value by cluster.
- Create a dashboard with filters and explanatory labels.
- Write a short interpretation of the business characteristics of each cluster.
Suggested Dashboard Components
- Cluster Overview: Number of customers in each cluster.
- Sales by Cluster: Total revenue contributed by each group.
- Order Frequency: Average orders per customer.
- Spending Comparison: Compare annual sales and average order value.
- Customer Detail: A table showing customers and their assigned clusters.
- Filters: Region, customer type, or date range where appropriate.
19. Other Business Applications
19.1 Product Segmentation
Group products according to sales, profit, quantity sold, and return rates. This may help identify high-performing products, low-volume products, or products that require further investigation.
19.2 Regional Segmentation
Compare regions using sales, profit margin, customer count, and order frequency. Clusters may reveal areas with similar business performance.
19.3 Marketing Campaign Segmentation
Analyze campaign cost, clicks, conversions, and revenue to discover groups of campaigns with similar outcomes.
19.4 Retail Store Segmentation
Group stores according to revenue, foot traffic, transaction count, and product mix to support operational planning.
19.5 Employee Performance Segmentation
Use appropriate workforce metrics to explore patterns in training, performance, and experience. Interpret the results carefully and avoid treating cluster membership as a standalone judgment of an employee.
20. Clustering Limitations in Tableau
- Clustering is available in Tableau Desktop and Tableau Public, but built-in clustering is not available for web authoring in Tableau Server or Tableau Cloud.
- Clustering is unavailable for certain data sources and views, including cube data sources and views with blended dimensions.
- The view must contain suitable fields for clustering; some field types cannot be used as clustering variables.
- Dates, table calculations, blended calculations, groups, sets, bins, parameters, and Measure Names or Measure Values cannot be used as clustering inputs in the built-in feature.
- Missing values can cause marks to be assigned to Not Clustered.
- The number and quality of clusters depend on the selected variables and level of detail.
- Clusters indicate similarities, not necessarily causal relationships.
- A cluster is not automatically a meaningful business segment until it has been interpreted and validated.
21. Common Problems and Solutions
| Problem |
Possible Cause |
Solution |
| Cluster option is unavailable |
The view or data source does not meet clustering requirements. |
Check the data source, view structure, and eligible input fields. |
| Many marks are Not Clustered |
Some clustering inputs contain null values or unsupported mixed categorical values. |
Inspect missing values and check the selected variables. |
| Clusters are difficult to explain |
Variables are irrelevant, redundant, or poorly chosen. |
Review the business objective and test a smaller set of useful variables. |
| One variable dominates the interpretation |
The variable has extreme values or an unusual distribution. |
Inspect outliers and understand Tableau's scaling behavior. |
| Too many clusters are created |
The chosen cluster count may be too detailed for the business question. |
Compare smaller cluster counts and review their usefulness. |
| Clusters change after editing |
Variables, data, level of detail, or cluster count have changed. |
Document the model settings and compare the updated results. |
| Saved group does not update |
The saved group is separate from the original clustering model. |
Review the cluster results and update the saved group when needed. |
22. Best Practices for Clustering and Segmentation
- Define the business objective before selecting variables.
- Choose variables that represent meaningful differences between observations.
- Ensure that the level of detail matches the entity being segmented.
- Check missing values, duplicates, and unusual observations.
- Compare different numbers of clusters rather than relying blindly on one setting.
- Review cluster centers, sizes, and variable statistics.
- Use understandable labels only after examining the actual cluster profiles.
- Validate clusters against business knowledge or other available evidence.
- Reassess cluster assignments when the underlying data changes significantly.
- Avoid assuming that correlation or similarity proves causation.
- Document the variables and settings so the analysis can be reproduced.
23. Interview Questions and Answers
Q1. What is clustering in Tableau?
Clustering in Tableau groups marks according to similarities in selected variables. It is an unsupervised learning technique used to discover patterns in data.
Q2. What is segmentation?
Segmentation is the process of dividing a population or dataset into meaningful groups. The groups can be defined using business rules or statistical techniques such as clustering.
Q3. Which algorithm does Tableau use for built-in clustering?
Tableau uses the K-means clustering algorithm for its built-in clustering feature.
Q4. What is a centroid?
A centroid is the center of a cluster, calculated as the mean of the observations assigned to it for the clustering variables.
Q5. How do you create clusters in Tableau?
Create a suitable visualization, open the Analytics pane, drag Cluster into the view, select variables, and configure the number of clusters.
Q6. What is the purpose of normalization?
Normalization places variables on comparable scales so that differences in numerical magnitude are less likely to dominate distance calculations.
Q7. How do you determine the number of clusters?
You can specify a number or allow Tableau to select one using its cluster-quality criterion. Compare the results for interpretability and business usefulness.
Q8. What is the difference between clustering and grouping?
Clustering uses an algorithm to discover groups based on similarities. Grouping usually combines selected dimension members manually or according to defined rules.
Q9. Can clusters be reused in other worksheets?
Yes. You can save cluster results as a group dimension and use that group in other worksheets, subject to Tableau's grouping constraints.
Q10. What does Not Clustered mean?
It generally indicates that Tableau could not assign a mark to a normal cluster, for example because a clustering input contains missing values or incompatible categorical information.
Q11. Does a higher cluster number mean better performance?
No. Cluster numbers are identifiers, not rankings. You must inspect the variables and characteristics of each cluster to interpret its meaning.
Q12. What is one limitation of K-means clustering?
K-means can be sensitive to outliers and variable selection, and it works best when the chosen variables and resulting cluster structure are appropriate for the distance-based model.
24. Practice Exercises
- Create a customer segmentation using total sales and order count.
- Compare the results using two, three, and four clusters.
- Use Describe Clusters to identify the variables that distinguish the groups.
- Save the cluster results as a group and rename the groups using evidence from the data.
- Build a chart showing total sales by cluster.
- Create a product segmentation using sales, profit, and quantity sold.
- Investigate how missing values affect the cluster results.
- Compare clusters created with different variable combinations.
- Build a dashboard containing cluster sizes, sales metrics, and customer details.
- Write a business recommendation based on the observed cluster profiles.
25. Quick Revision Checklist
- Understand clustering, segmentation, and unsupervised learning.
- Know the basics of the K-means algorithm.
- Prepare the data and select an appropriate level of detail.
- Choose meaningful clustering variables.
- Use the Analytics pane to create clusters.
- Compare cluster counts and review model quality.
- Use Describe Clusters to understand the results.
- Save clusters as groups when they need to be reused.
- Recognize missing-data issues and clustering limitations.
- Translate cluster characteristics into carefully validated business insights.
26. Official Documentation and Learning Resources
27. Conclusion
Clustering and Segmentation help analysts discover meaningful groups within large datasets. Tableau's built-in K-means clustering feature makes it possible to identify patterns visually, examine cluster characteristics, and save results for reuse. By choosing relevant variables, checking data quality, comparing different cluster counts, and validating the results, analysts can build more informative dashboards and support better business decisions.